code to control views being private/public

Hi guys, here is my code to check if the views inside the module match any of the strings inside the arrays (which contain the original views).

TooDiff
 

View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
 
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
 
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
    for s in views(m) do
        {
                bool equal = false
 
                //MRD = 0 //counter for generic loop below
                for MRD in 0:3 do
                {
                        //Comparison code here
                        if (s == viewsMRD[MRD])  
                        { 
                                equal = true
                                print MRD "\n"                        
                        }
                        else 
                        {
                                print MRD "\n"
                        }
                }
                if (equal != true)
                {
                        v = view(s) //handle to current view in loop
                        res = set(v,none,null)
                        print "It's done."
                        if(!null res)
                        {
                                ack("Error setting permissions in at least 1 view.")
                        }
                }
                        
        }
} 
 
 
for moduleitem in current Project do
{    
        MRD=0
        PTR=1
        QA=0
        FMEA=0 //Reset counters
 
        if((type moduleitem) == "Formal")
        {
                modulename = fullName(moduleitem)
                modulechecker = name(moduleitem) //just get name of module not path
                print modulechecker
                //print modulename
                
                if(name(moduleitem) == "MRD")
                { 
                        edit(modulename, true, true, false)
                        Module moo = current
                        compareMRD(MRD,moo) 
                }
 
                Module moo = current
                save(moo)
                //close(m,false)
 
        }
}

TooDifficult - Wed Dec 22 00:08:09 EST 2010

Re: code to control views being private/public
TooDifficult - Wed Dec 22 00:11:59 EST 2010

Hi guys, here is my code to check if the views inside the module match any of the strings inside the arrays (which contain the original views).

The code runs fine, but when it gets to a non-matching view, that is, a user-added view, the set-view permission statement stops working. I get the if null case, and then the error message.

When I go into the manage views tab to have a look at the permissions, I see myloginname RMCDA, and also Everyone R

That is, I see 2 separate permission sets, whereas each of the original ones only have Everyone RMCDA.

In other words, the code is not working. It runs through the loops fine, I just don't know what is affecting the success of that set-view statement.
Any idea what's wrong? Is it because I have the view in the active window that the script can't run on it? Simply because it's being 'edited' when the script means to set it to no-access?

Thanks,

TooDiff

Re: code to control views being private/public
TooDifficult - Wed Dec 22 00:15:11 EST 2010

Also, that set statement seems to work very selectively. I've made an include file that contains all the functions to generate a module with pre scripted views and attributes. After the code line to save the views, I've also added a set view permissions statement, which makes the pre scripted view read only to users.

Re: code to control views being private/public
TooDifficult - Wed Dec 22 00:16:04 EST 2010

Hi guys, here is my code to check if the views inside the module match any of the strings inside the arrays (which contain the original views).

The code runs fine, but when it gets to a non-matching view, that is, a user-added view, the set-view permission statement stops working. I get the if null case, and then the error message.

When I go into the manage views tab to have a look at the permissions, I see myloginname RMCDA, and also Everyone R

That is, I see 2 separate permission sets, whereas each of the original ones only have Everyone RMCDA.

In other words, the code is not working. It runs through the loops fine, I just don't know what is affecting the success of that set-view statement.

Also, that set statement seems to work very selectively. I've made an include file that contains all the functions to generate a module with pre scripted views and attributes. After the code line to save the views, I've also added a set-view permissions statement, which makes the pre scripted view read only to users.

Funny thing is, this thing only works for the default view. So only one of the views has been affected by the set statement; the rest all remain Everyone RMCDA.

Any idea what's wrong? Is it because I have the view in the active window that the script can't run on it? Simply because it's being 'edited' when the script means to set it to no-access?

Thanks,

TooDiff

Re: code to control views being private/public
TooDifficult - Wed Dec 22 00:17:39 EST 2010

sorry for the crazy posts guys stupid text filter doesn't want me to post "pre-scripted" without the hyphen , says it's disallowed content >_> spent 3 posts trying to figure out the culprit gargh

Re: code to control views being private/public
llandale - Wed Dec 22 01:41:50 EST 2010

Looks like you are trying to make a bunch of named views invisible to 'Everybody else'.

First off, you don't need to 'edit' the module, you can modify views in 'read' mode, and saving the view is enough you don't save the module.

Perhaps some of your views have 'inherited' access and therefore you cannot modify the individual settings, you'd need to change the view to 'specific' first. I don't have my DXL manual handy, but I think the following will help

bool IsInherit
isInherit(v, IsInherit)
if (IsInherit) then specific(v) // or is is 'setSpecific'?
// now try to set the view

Now I wonder if you must save the view. To do that you may need to first load the view, change its access, and save it but I don't recall. But surely someone will help me out on that.

-Louie

If you must save the module, you should do this:
Module moo = edit(...)
bla bla bla
save(moo)
close(moo)

Relying on 'current module' to get your handle is hopeless.

Re: code to control views being private/public
TooDifficult - Wed Dec 22 16:55:19 EST 2010

Hi Louie,

Thanks for the reply.

Thanks for your checker snippet. I've also found the problem by having a look at the access control code example in the DXL Manual.

The problem seems to be that set only takes read|modify|delete|control? I do not see "none" as part of those choices.

Is it possible to make a selection of that particular option in some other way?

the set statement works fine with modify or delete. I see the access right change to RM or RMCD, etc.

Thanks,

2Diff

Re: code to control views being private/public
TooDifficult - Wed Dec 22 17:00:49 EST 2010

Louie,

Never mind what I said. Another check shows that none is indeed available.
 

// Make all views private by removing "Everyone Else" permissions
/*string s   = ""   //Will store the name of a view
string res = ""   //Will store the returned result from a function
View   v   = null*/
 
 
View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
 
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
 
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
    for s in views(m) do
        {
                bool equal = false
 
                //MRD = 0 //counter for generic loop below
                for MRD in 0:3 do
                {
                        //Comparison code here
                        if (s == viewsMRD[MRD])  
                        { 
                                equal = true
                                print MRD "\n"        
                                print equal     "\n"  
                        }
                        else 
                        {
                                print MRD "\n"
                        }
                }
                if (equal != true)
                {
                        print "Get rid of this one \n"
                        
                        v = view(s) //handle to current view in loop
                        bool IsAccessInherited
                        isAccessInherited(v,IsAccessInherited)
                        if (IsAccessInherited == true)
                        {
                                specific(v)
                        }
                        res = set(v,none,null)
                                
                                if(!null res)
                                {
                                        ack("Error setting permissions in at least 1 view.")
                                }
                }                                                    
        }
} 
 
 
for moduleitem in current Project do
{    
        MRD=0
        PTR=1
        QA=0
        FMEA=0 //Reset counters
 
        if((type moduleitem) == "Formal")
        {
                modulename = fullName(moduleitem)
                modulechecker = name(moduleitem) //just get name of module not path
                
                if(name(moduleitem) == "MRD")
                { 
                        Module moo = edit(modulename, true, true, false)
                        compareMRD(MRD,moo) 
                }
 
                Module moo = current
                save(moo)
                //close(m,false)
 
        }
}

 


Something up with the set function i think.

Setting specific access rights doesn't seem to have solved the problem...

-2Diff

 

Re: code to control views being private/public
llandale - Wed Dec 22 19:05:32 EST 2010

TooDifficult - Wed Dec 22 17:00:49 EST 2010

Louie,

Never mind what I said. Another check shows that none is indeed available.
 

// Make all views private by removing "Everyone Else" permissions
/*string s   = ""   //Will store the name of a view
string res = ""   //Will store the returned result from a function
View   v   = null*/
 
 
View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
 
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
 
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
    for s in views(m) do
        {
                bool equal = false
 
                //MRD = 0 //counter for generic loop below
                for MRD in 0:3 do
                {
                        //Comparison code here
                        if (s == viewsMRD[MRD])  
                        { 
                                equal = true
                                print MRD "\n"        
                                print equal     "\n"  
                        }
                        else 
                        {
                                print MRD "\n"
                        }
                }
                if (equal != true)
                {
                        print "Get rid of this one \n"
                        
                        v = view(s) //handle to current view in loop
                        bool IsAccessInherited
                        isAccessInherited(v,IsAccessInherited)
                        if (IsAccessInherited == true)
                        {
                                specific(v)
                        }
                        res = set(v,none,null)
                                
                                if(!null res)
                                {
                                        ack("Error setting permissions in at least 1 view.")
                                }
                }                                                    
        }
} 
 
 
for moduleitem in current Project do
{    
        MRD=0
        PTR=1
        QA=0
        FMEA=0 //Reset counters
 
        if((type moduleitem) == "Formal")
        {
                modulename = fullName(moduleitem)
                modulechecker = name(moduleitem) //just get name of module not path
                
                if(name(moduleitem) == "MRD")
                { 
                        Module moo = edit(modulename, true, true, false)
                        compareMRD(MRD,moo) 
                }
 
                Module moo = current
                save(moo)
                //close(m,false)
 
        }
}

 


Something up with the set function i think.

Setting specific access rights doesn't seem to have solved the problem...

-2Diff

 

Wild try, perhaps set(v, none, "") works better. I never use "null" to mean the empty string and I have a long time ago proved there is a slight difference between the two, so perhaps that may work. Also, your 'ack' might as well display the error 'res'ults; perhaps there's a clue there.

Re: code to control views being private/public
SystemAdmin - Wed Dec 22 23:00:48 EST 2010

llandale - Wed Dec 22 19:05:32 EST 2010
Wild try, perhaps set(v, none, "") works better. I never use "null" to mean the empty string and I have a long time ago proved there is a slight difference between the two, so perhaps that may work. Also, your 'ack' might as well display the error 'res'ults; perhaps there's a clue there.

Louie - TooDifficult had another recent posting in the DXL forum on a very similar topic and I suggested that he use set(v,null,"") which works as a means to assign "None" as the permissions to the default "Everyone" group - this seems contrary to your recommendation to steer away from using "null" as an operator, but I just want to check that your recommendation is limited to using "null" to represent an empty string only. In this particular case, the data type of the argument in question in the set() function is the Permissions operator\data type - as far as I know, if the data type is not a string, then the use of "null" should be OK without any side effects - do you agree with this or have you found otherwise, just like for the empty string?
Paul Miller
Melbourne, Australia

Re: code to control views being private/public
Mathias Mamsch - Thu Jan 06 17:38:40 EST 2011

llandale - Wed Dec 22 19:05:32 EST 2010
Wild try, perhaps set(v, none, "") works better. I never use "null" to mean the empty string and I have a long time ago proved there is a slight difference between the two, so perhaps that may work. Also, your 'ack' might as well display the error 'res'ults; perhaps there's a clue there.

(null string) and the empty string are identical, the only problem is that a lot of times the expression "null" will evaluate to '_y null()' instead of the the 'string null()' function, which will yield trouble in some cases. The 'string null()' function returns the empty string. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: code to control views being private/public
llandale - Fri Jan 07 10:31:28 EST 2011

Mathias Mamsch - Thu Jan 06 17:38:40 EST 2011
(null string) and the empty string are identical, the only problem is that a lot of times the expression "null" will evaluate to '_y null()' instead of the the 'string null()' function, which will yield trouble in some cases. The 'string null()' function returns the empty string. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Somewhere I have proved an isolated case where "null" string was not the same as assigning an empty string; I'll have to dig that out. I wonder if its really as you said the y_ version of the function. But I will say that often I must do this:
if (null s) s = ""
in order to deal with strange function parameter behavior.

I'm suspecting that an empty string isn't null, its just empty but the null(string) function returns true in both cases, and retrieving the string value returns the same value (no characters).

In any case I avoid s=null; I always set it empty: s="".

  • Louie

Re: code to control views being private/public
llandale - Fri Jan 07 10:41:21 EST 2011

SystemAdmin - Wed Dec 22 23:00:48 EST 2010
Louie - TooDifficult had another recent posting in the DXL forum on a very similar topic and I suggested that he use set(v,null,"") which works as a means to assign "None" as the permissions to the default "Everyone" group - this seems contrary to your recommendation to steer away from using "null" as an operator, but I just want to check that your recommendation is limited to using "null" to represent an empty string only. In this particular case, the data type of the argument in question in the set() function is the Permissions operator\data type - as far as I know, if the data type is not a string, then the use of "null" should be OK without any side effects - do you agree with this or have you found otherwise, just like for the empty string?


Paul Miller
Melbourne, Australia

I've had no problem with "null" except when dealing with "strings"; and yes it appears Permission none == Permission null. "none" is slightly better I think since its easier to read for the reader 6 months later; and who knows maybe next year there will be some other "set" function that has something other than "Permission" as the 2nd parameter; and that new function has search precedence over this one, and then the code stops working (much like "o = target(Link)" changed meaning when you had auto declare, in v7 in meant "Object o" in v8 it meant "ModRef_ o").

  • Louie

OK, so I had an issue with "null" vis-a-vis characters, but I think I resolve that by using "charOf(0)" which is ASCII null. c=null means erase it; c=charOf(0) means set it to ascii null. and buf[5]=charof(0) truncated the Buffer except when used by tempStringOf(buf), but I digress....